Skip to content

perf: enhance tokens block memory usage - #486

Open
cheb0 wants to merge 4 commits into
mainfrom
0-enhance-token-block-memory
Open

perf: enhance tokens block memory usage#486
cheb0 wants to merge 4 commits into
mainfrom
0-enhance-token-block-memory

Conversation

@cheb0

@cheb0 cheb0 commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Description

Measurements

Memory

Memory reduction (prod fraction):

message:*foobar*
25335032 => 20584912 bytes

message:*87466437*
71844952 => 58236912

Query perf

V5 fractions
For V5 fractions (current version) we have same cold perf - unpack is unchanged, same hot perf for contains wildcard but a little slowdown for wildcards like suffix since GetToken is now includes version check and it's a bit more expensive. Please see the code of Block and contains function.

Query env Total cold, ms   hot, ms   cold (branch), ms   hot (branch), ms   cold diff hot diff
message:eldorado prod 0 96.52 ±3.54 11.99 ±0.09 97.22 ±2.77 12.03 ±0.24 0.7% 0.3%
request:010462589104432 prod 0 115.6 ±7.44 16.85 ±0.34 117.49 ±5.33 16.79 ±0.23 1.6% -0.4%
request:*010462589104432 prod 0 119.37 ±6.02 15.05 ±0.09 125.76 ±6.97 15.96 ±0.15 5.4% 6%

V6 fractions

For V6 (new format) we have slightly better cold perf - unpack is more cheap.

For hot queries it's also slightly faster for contains wildcards since getting a token is a bit more cheap and the new implementation has BCE optimization as well. Same for arbitrary wildcards - slightly more expensive GetToken, I suppose.

Query env Total cold, ms   hot, ms   cold (branch), ms   hot (branch), ms   cold diff hot diff
message:eldorado prod 0 96.52 ±3.54 11.99 ±0.09 93.14 ±4.48 9.87 ±0.15 -3.5% -17.7%
request:010462589104432 prod 0 115.6 ±7.44 16.85 ±0.34 107.73 ±7.44 15.29 ±0.20 -6.8% -9.3%
request:*010462589104432 prod 0 119.37 ±6.02 15.05 ±0.09 109.29 ±5.45 16.11 ±0.32 -8.4% 7%

  • I have read and followed all requirements in CONTRIBUTING.md;
  • I used LLM/AI assistance to make this pull request;

@codecov-commenter

codecov-commenter commented Aug 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 63.93443% with 22 lines in your changes missing coverage. Please review.
✅ Project coverage is 71.01%. Comparing base (6372ee9) to head (2468d53).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
frac/sealed/token/block_loader.go 60.00% 18 Missing and 4 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #486      +/-   ##
==========================================
- Coverage   71.12%   71.01%   -0.11%     
==========================================
  Files         232      232              
  Lines       18404    18544     +140     
==========================================
+ Hits        13089    13169      +80     
- Misses       4337     4391      +54     
- Partials      978      984       +6     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@dkharms

dkharms commented Aug 6, 2026

Copy link
Copy Markdown
Member

@seqbenchbot start search-regular main 'k8s_pod:-eu-' --duration 5m

@seqbenchbot

seqbenchbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Started benchmark 58d2faa3.

Show details
  • scenario search-regular;
  • against main;
  • running for 5m0s;

I'll post the statistics here once it finishes.
To end it early, run @seqbenchbot stop 58d2faa3.

Here is a list of helpful links:

  • Take a look at Grafana dashboard;
  • Live-tailing logs are also available;

Have a great time!

@seqbenchbot

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Benchmark 58d2faa3 (scenario search-regular) has finished.
I've prepared a summary for you. Click on Show summary button to see it:

Show summary
Query Type mean (ms) stddev (ms) p(50) (ms) p(95) (ms) p(99) (ms) iterations total
k8s_pod:*-eu-*
hot 11.80 0.74 12.17 17.54 18.20 2992 1437046

Compare it against another run with @seqbenchbot compare 58d2faa3 <other-id>.

@dkharms

dkharms commented Aug 6, 2026

Copy link
Copy Markdown
Member

@seqbenchbot start search-regular 0-enhance-token-block-memory 'k8s_pod:-eu-' --duration 5m

@seqbenchbot

seqbenchbot commented Aug 6, 2026

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Started benchmark 43c61a79.

Show details
  • scenario search-regular;
  • against 0-enhance-token-block-memory;
  • running for 5m0s;

I'll post the statistics here once it finishes.
To end it early, run @seqbenchbot stop 43c61a79.

Here is a list of helpful links:

  • Take a look at Grafana dashboard;
  • Live-tailing logs are also available;

Have a great time!

@seqbenchbot

Copy link
Copy Markdown
Collaborator

Nice, @dkharms <(-^,^-)=b!

Benchmark 43c61a79 (scenario search-regular) has finished.
I've prepared a summary for you. Click on Show summary button to see it:

Show summary
Query Type mean (ms) stddev (ms) p(50) (ms) p(95) (ms) p(99) (ms) iterations total
k8s_pod:*-eu-*
hot 12.15 2.71 10.95 16.47 17.00 2992 1437020

Compare it against another run with @seqbenchbot compare 43c61a79 <other-id>.

@dkharms dkharms added the performance Features or improvements that positively affect seq-db performance label Aug 6, 2026
@eguguchkin eguguchkin added this to the v0.77.0 milestone Aug 10, 2026
@eguguchkin
eguguchkin requested review from forshev and moflotas August 10, 2026 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

performance Features or improvements that positively affect seq-db performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants